local skel = fk.CreateSkill {
  name = "lb__lianshi",
}

Fk:loadTranslationTable {
  ["lb__lianshi"] = "莲蚀",
  --[":lb__lianshi"] = "每回合开始时，你可以观看当前回合角色手牌，秘密选择其中一张牌，此牌本回合内被使用时少结算一次，且若下一张被使用的牌为基本牌或普通锦囊牌，则额外结算一次。",
  --10.19
  [":lb__lianshi"] = "每回合开始时，你可以观看当前回合角色手牌，秘密选择其中一张牌，此牌本回合内被使用时少结算一次。若如此做，本回合下一张牌额外结算一次。",

  
  ["#lb__lianshi"] = "莲蚀：你可以观看%dest的手牌并秘密选择其中一张牌，此牌本回合内被使用时，少结算一次",
  ["#lb__lianshi_choose"] = "莲蚀：请秘密选择%dest的一张手牌，此牌本回合内被使用时，少结算一次",

  ["$lb__lianshi1"] = "",
  ["$lb__lianshi2"] = "",
}

skel:addEffect(fk.TurnStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target:isAlive() and not target:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#lb__lianshi::" .. target.id, })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "lb__lianshi-turn", 1)
    local ids = room:askToChooseCardsAndChoice(player, {
      cards = target:getCardIds("h"),
      skill_name = skel.name,
      prompt = "#lb__lianshi_choose::" .. target.id,
      min_num = 1,
      max_num = 1,
    })
    if #ids > 0 then
      room:setCardMark(Fk:getCardById(ids[1]), "lb__lianshi-turn", player.id)
    end
  end,
})

skel:addEffect(fk.CardUsing, {
  priority = 0.001,
  anim_type = "control",
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and data.card:getMark("lb__lianshi-turn") == player.id
  end,
  on_use = function(self, event, target, player, data)
    local num = (data.additionalEffect or 0) - 1
    if num < 0 then
      data.toCard = nil--令牌失效
      data.tos = {}
    else
      data.additionalEffect = num
    end
  end,
})

skel:addEffect(fk.CardUsing, {
  anim_type = "support",
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name, true) and player:getMark("lb__lianshi-turn") == 1 then
      player.room:setPlayerMark(player, "lb__lianshi-turn", 0)
      return player:hasSkill(skel.name) --and (data.card.type == Card.TypeBasic or data.card:isCommonTrick())
    end
  end,
  on_use = function(self, event, target, player, data)
    data.additionalEffect = (data.additionalEffect or 0) + 1
  end,
})

return skel